<%--
  Created by IntelliJ IDEA.
  User: liguanchen0629
  Date: 2021/6/24
  Time: 9:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>主页</title>
<%
	pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<script src="${APP_PATH}/static/js/jquery-3.1.1.min.js"></script>
<link rel="stylesheet"
	href="${APP_PATH}/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
<script
	src="${APP_PATH}/static/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
</head>
<body>
	<!-- <h1>成功!</h1>
<table border="1" cellspacing="0" cellpadding="0" class="table1">
    <tr>
        <th width="400px">id</th>
        <th width="500px">price</th>
        <th width="300px">brand</th>
        <th width="300px">type</th>
        <th width="300px">number</th>
        <th width="200px">操作</th>
    </tr> -->
	<div class="container">
		<!-- 标题行 -->
		<div class="row">
			<div class="col-xs-12">
				<h1>首页</h1>
			</div>
		</div>
		<!-- 显示表格数据 -->
		<div class="row">
			<div class="col-md-10"></div>
			<div class="col-md-2">
				<form action="${APP_PATH }/something/findOrderById" method="post">
					<button type="submit" class="btn btn-info btn-sm">查看订单</button>
				</form>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<table class="table table-hover">
					<tr>
						<th>id</th>
						<th>price</th>
						<th>brand</th>
						<th>type</th>
						<th>number</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
					<c:forEach items="${info.list }" var="car">
						<tr>
							<th>${car.id }</th>
							<th>${car.price }</th>
							<th>${car.brand}</th>
							<th>${car.type}</th>
							<th>${car.number}</th>
							<th>${car.state?"有":"无" }</th>
							<th>
								<%--  <button class="btn btn-danger btn-sm" id="do_btn"
									onclick="userOrder(${car.id})">
									<span class="glyphicon glyphicon-ok" aria-hidden="true">预定
									</span>
								</button> --%>
								<form action="${APP_PATH }/something/pay?id=${car.id}"
									method="post">
									<button type="submit" class="btn btn-danger btn-sm">预定</button>
								</form>

							</th>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>
		<!-- 分页信息 -->
		<div class="row">
			<!-- 分页文字信息 -->
			<div class="col-md-6">当前${info.pageNum }页,总${info.pages }页,总${info.total }条记录
			</div>
			<!-- 分页条信息 -->
			<div class="col-md-6">
				<nav aria-label="Page navigation">
					<ul class="pagination">
						<li><a href="${APP_PATH }/car/getall?pn=1">首页</a></li>
						<c:if test="${info.hasPreviousPage }">
							<li><a href="${APP_PATH }/car/getall?pn=${info.pageNum-1}"
								aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
							</a></li>
						</c:if>
						<c:forEach items="${info.navigatepageNums }" var="page_Num">
							<c:if test="${page_Num == info.pageNum }">
								<li class="active"><a href="#">${page_Num }</a></li>
							</c:if>
							<c:if test="${page_Num != info.pageNum }">
								<li><a href="${APP_PATH }/car/getall?pn=${page_Num}">${page_Num}</a></li>
							</c:if>
						</c:forEach>
						<c:if test="${info.hasNextPage }">
							<li><a href="${APP_PATH }/car/getall?pn=${info.pageNum+1}"
								aria-label="Next"> <span aria-hidden="true">&raquo;</span>
							</a></li>
						</c:if>

						<li><a href="${APP_PATH }/car/getall?pn=${info.pages}">末页</a></li>
					</ul>
				</nav>
			</div>
		</div>
	</div>
	<%-- <tr class="tr01">
       <td width="400px">
           <b>车辆图片</b>
       </td>
       <td width="500px">
           <b>车辆名称</b>
       </td>
       <td width="300px">
           <b>车辆品牌</b>
       </td>
       <td width="200px">
           <b>剩余数量</b>
       </td>
       <td width="200px">
           <b>单价（元/天）</b>
       </td>
       <td width="200px">
           <b>操作</b>
   </tr>--%>
	<%-- 		<c:forEach items="${info.list}" var="car">
                <tr height="100px">
                    <td>${car.id}</td>
                    <td>${car.price}</td>
                    <td>${car.brand}</td>
                    <td>${car.type}</td>
                    <td>${car.number}</td>
                    <td><button>租车</button>
                        <button>取消</button></td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="4"><a href="getall?pn=1">首页</a> <a
                    href="getall?pn=${info.prePage}">上一页</a> <c:forEach
                        items="${info.navigatepageNums}" var="num">
                        <c:if test="${num==info.pageNum}">
                        【${num}】
                    </c:if>
                        <c:if test="${num!=info.pageNum}">
                            <a href="getall?pn=${num}">${num}</a>
                        </c:if>

                    </c:forEach> <a href="getall?pn=${info.nextPage}">下一页</a> <a
                    href="getall?pn=${info.pages}">末页</a></td>
            </tr>
        </table> --%>

	<script type="text/javascript">
		function userOrder(id) {
			if (confirm('确定要预定该车辆吗？')) {
				$.ajax({
					url : "${APP_PATH }/something/pay",
					data : {
						"id" : id
					},
					type : 'POST'
				/* success : function(data) {
					if (data == "OK") {
						alert("删除成功");
						window.location.reload();
					} else {
						alert("删除失败");
						window.location.reload();
					}
				} */

				})
			}
		};
	</script>
</body>
</html>
